﻿using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Framework.Serialization;
using LFloatMath.Math;

namespace IQIGame.Onigao.GamePlay
{
    public class ImpactResponse : IReusableClassWithFree, ISerializeCustomPOD
    {
        public LFloat speed;
        public LVector2 aspect;
        public LVector2 targetPos;
        public SkillEffectivePackageResponse packageResp;

        public uint MaxStore { get; }

        public void OnReset()
        {
            if (this.packageResp != null)
            {
                this.packageResp.Free();
            }
            this.packageResp = null;
            this.speed = default;
            this.aspect = default;
            this.targetPos = default;
        }

        public void Free()
        {
            ClassPool.Put(this);
        }

        public void Serialize(SOutputStream _buf)
        {
            _buf.Write_long(this.speed._val);
            _buf.Write_long(this.aspect.x._val);
            _buf.Write_long(this.aspect.y._val);
            _buf.Write_long(this.targetPos.x._val);
            _buf.Write_long(this.targetPos.y._val);
            SerializeCustomPODUtil.SerializeObject(_buf, this.packageResp);
        }

        public void DeSerialize(SInputStream _buf)
        {
            this.speed = new LFloat(true, _buf.Read_long());
            this.aspect = new LVector2(new LFloat(true, _buf.Read_long()), new LFloat(true, _buf.Read_long()));
            this.targetPos = new LVector2(new LFloat(true, _buf.Read_long()), new LFloat(true, _buf.Read_long()));
            SerializeCustomPODUtil.DeSerializeObject(_buf, ref this.packageResp);
        }
    }
}